#ifndef OLED_H
#define OLED_H
//宏定义
#define FALSE  -1
#define TRUE   0

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//  Pin Definition
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


#define RES_CLR       oled_res_set_value(0)
#define RES_SET       oled_res_set_value(1)

#define DC_CLR        oled_dc_set_value(0)
#define DC_SET        oled_dc_set_value(1)

#define SCLK_CLR      oled_sclk_set_value(0)
#define SCLK_SET      oled_sclk_set_value(1)

#define SDIN_CLR      oled_sdin_set_value(0)
#define SDIN_SET      oled_sdin_set_value(1)

#define CS_CLR        oled_cs_set_value(0)
#define CS_SET        oled_cs_set_value(1)

#define CS_ZK_CLR     oled_cs_zk_set_value(0)
#define CS_ZK_SET     oled_cs_zk_set_value(1)

#define SDO_READ  oled_sdo_zk_get_value()
void oled_res_set_value(char v);
void oled_dc_set_value(char v);
void oled_sclk_set_value(char v);
void oled_sdin_set_value(char v);
void oled_cs_set_value(char v);
void oled_cs_zk_set_value(char v);
unsigned int oled_sdo_zk_get_value(void);

void u_gpio_init(void);
void u_oled_init(void);
void u_oled_clear(void);
void oled_startup_init(void);
void vendor_display(char *s);
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#define	Shift		0x1C
#define    Max_Column	0x3F			// 256/4-1
#define    Max_Row		0x3F			// 64-1
#define	Brightness	0xff

//add later
void gpio_set_value(int gpio, int value);
int gpio_get_value(int gpio);
int gpio_direction_input(int gpio);
int gpio_direction_output(int gpio, int value);
int gpio_request(int gpio, const char *label);
void gpio_free(int gpio);
//SPI函数
void Write_Command(unsigned char Data);
void Write_Data(unsigned char Data);

//oled函数
void OLED_Init(void);
void Set_Column_Address(unsigned char a, unsigned char b);
void Set_Row_Address( unsigned char a, unsigned char b);
void Set_Write_RAM(void);
void Set_Read_RAM(void);
void Set_Remap_Format(unsigned char d);
void Set_Start_Line(unsigned char d);
void Set_Display_Offset(unsigned char d);
void Set_Display_Mode(unsigned char d);
void Set_Partial_Display(unsigned char a, unsigned char b, unsigned char c);
void Set_Function_Selection(unsigned char d);
void Set_Display_On_Off(unsigned char d);
void Set_Phase_Length(unsigned char d);
void Set_Display_Clock(unsigned char d);
void Set_Display_Enhancement_A(unsigned char a, unsigned char b);
void Set_GPIO(unsigned char d);
void Set_Precharge_Period(unsigned char d);
void Set_Precharge_Voltage(unsigned char d);
void Set_VCOMH(unsigned char d);
void Set_Contrast_Current(unsigned char d);
void Set_Master_Current(unsigned char d);
void Set_Multiplex_Ratio(unsigned char d);
void Set_Display_Enhancement_B(unsigned char d);
void Set_Command_Lock(unsigned char d);


//延时函数
void uDelay(unsigned long usec);


//显示命令函数
void Draw_Rectangle(unsigned char Data, unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e);
void Fill_RAM(unsigned char Data);
void Fill_Block(unsigned char Data, unsigned char a, unsigned char b, unsigned char c, unsigned char d);
void Grayscale(void);
void Show_Pattern(unsigned char *Data_Pointer, unsigned char a, unsigned char b, unsigned char c, unsigned char d);
void Vertical_Scroll(unsigned char a, unsigned char b, unsigned char c);
void Fade_Scroll(unsigned char a, unsigned char b, unsigned char c);
void Fade_In(void);
void Fade_Out(void);
void Set_Gray_Scale_Table(void);
void Set_Linear_Gray_Scale_Table(void);
void con_4_byte(unsigned char DATA);

//字库函数
void send_command_to_ZK( unsigned char dat);
 unsigned char ZK_read(void);
void ZK_Read_1_n(unsigned char addrHigh,unsigned char addrMid,unsigned char addrLow,unsigned char *pBuff,unsigned char DataLen );
void Display_Asc_String(unsigned char zk_num,unsigned int x, unsigned int y, unsigned char  text[]);
void Display_Asc( unsigned char zk_num,unsigned int x, unsigned int y );

//
#endif
